---
slug: /api/documentation
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Inline Documentation

Dagger modules and Dagger Functions should be documented so that descriptions are shown in the API and the CLI - for example, when calling `dagger functions` and `dagger call ... --help`.

<Tabs groupId="language">
<TabItem value="Go">

The following code snippet shows how to add documentation for:

- The whole module
- Function methods
- Function arguments

```go file=./snippets/documentation/go/main.go
```

</TabItem>
<TabItem value="Python">

The following code snippet shows how to use Python's [documentation string conventions](https://peps.python.org/pep-0008/#documentation-strings) for adding descriptions to:
- The whole [module](https://docs.python.org/3/tutorial/modules.html) or [package](https://docs.python.org/3/tutorial/modules.html#packages)
- Object type classes (group of functions)
- Function methods
- Function arguments

For function arguments, [annotate](https://peps.python.org/pep-0727/#specification) with the [`dagger.Doc`](https://dagger-io.readthedocs.io/en/latest/module.html#dagger.Doc) metadata.

:::note
[`dagger.Doc`](https://dagger-io.readthedocs.io/en/latest/module.html#dagger.Doc) is just an alias for [`typing_extensions.Doc`](https://typing-extensions.readthedocs.io/en/latest/#Doc).
:::

<!-- loud_hello has a multi-line docstring on purpose -->
```python file=./snippets/documentation/python/main.py
```

</TabItem>
<TabItem value="TypeScript">

The following code snippet shows how to add documentation for:
- The whole module
- Function methods
- Function arguments

```typescript file=./snippets/documentation/typescript/index.ts
```

</TabItem>
<TabItem value="PHP">

The following code snippet shows how to add documentation for:

- The whole module
- Function methods
- Function arguments

```php file=./snippets/documentation/php/main/src/MyModule.php
```

</TabItem>
</Tabs>

Here is an example of the result from `dagger functions`:

```
Name         Description
hello        Return a greeting.
loud-hello   Return a loud greeting.
```

Here is an example of the result from `dagger call hello --help`:

```
Return a greeting.

USAGE
  dagger call hello [arguments]

ARGUMENTS
      --greeting string   The greeting to display [required]
      --name string       Who to greet [required]
```


The following code snippet shows how to add documentation for an object and its fields in your Dagger module:

<Tabs groupId="language">
<TabItem value="Go">

```go file=./snippets/documentation/go/object.go
```

</TabItem>
<TabItem value="Python">

```python file=./snippets/documentation/python/object.py
```

</TabItem>
<TabItem value="TypeScript">

```typescript file=./snippets/documentation/typescript/object.ts
```

</TabItem>
<TabItem value="PHP">

```php file=./snippets/documentation/php/object/src/MyModule.php
```

</TabItem>
</Tabs>

Here is an example of the result from `dagger call --help`:

```
ARGUMENTS
      --age int       The age of the user. [required]
      --name string   The name of the user. [required]
```
